﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using xKnight.Analyzing;
using xKnight.Analyzing.BaseAnalyze;
using xKnight.Analyzing.EncodedXss;
using xKnight.Analyzing.SimpleXss;
using xKnight.Models;
using xKnight.Attacking;

namespace xKnight.Analyzing
{
    class Program
    {
        static void Main(string[] args)
        {
            int attackId = 12;
            AnalyzeManager analyzeManager = new AnalyzeManager(attackId);

            analyzeManager.AnalyzeAnnounced += analyzeManager_AnalyzeAnnounced;
            analyzeManager.AnalyzeCompleted += analyzeManager_AnalyzeCompleted;
            analyzeManager.AnalyzeStarted += analyzeManager_AnalyzeStarted;

            analyzeManager.Analyze();

            Console.ReadLine();
        }

        static void analyzeManager_AnalyzeStarted(object sender, AnalyzeStartedEventArgs e)
        {
            DateTime dtStart = e.DateTime;

            Console.WriteLine("Analyzing Operation Started");
        }

        static void analyzeManager_AnalyzeCompleted(object sender, AnalyzeCompletedEventArgs e)
        {
            DateTime dtFinish = e.DateTime;

            Console.WriteLine("Analyzing Operation Finished");
        }

        static void analyzeManager_AnalyzeAnnounced(object sender, AnalyzeAnnouncedEventArgs e)
        {
            AnalyzeAnnounceItem announceItem = e.AnnounceItem;
            DateTime dateTime=announceItem.DateTime;
            string description=announceItem.Description;
            bool isSucceed=announceItem.Succeed;
            string url=announceItem.Url;

            if (announceItem is EncodedXssAnalyzeAnnounceItem)
            {
                EncodedXssAnalyzeAnnounceItem encodedXssAnalyzeAnnounceItem =
                    announceItem as EncodedXssAnalyzeAnnounceItem;

                string formAction = encodedXssAnalyzeAnnounceItem.FormAction;
                string formMethod = encodedXssAnalyzeAnnounceItem.FormMethod;
                XAttack xAttack = encodedXssAnalyzeAnnounceItem.XAttack;
            }
            else if (announceItem is SimpleXssAnalyzeAnnounceItem)
            {
                SimpleXssAnalyzeAnnounceItem simpleXssAnalyzeAnnounceItem =
                    announceItem as SimpleXssAnalyzeAnnounceItem;

                string formAction = simpleXssAnalyzeAnnounceItem.FormAction;
                string formMethod = simpleXssAnalyzeAnnounceItem.FormMethod;
                XAttack xAttack = simpleXssAnalyzeAnnounceItem.XAttack;
            }

            Console.WriteLine("Analyzing Operation Announced");
        }
    }
}
